<?php
/**
 * Created by PhpStorm.
 * User: liuhong
 * Date: 2018/11/21
 * Time: 下午1:34
 */

namespace Api\Service;


class ArticleService extends BaseService
{
    public $articleModel;
    public $articleTypeModel;
    public function __construct()
    {
        $this->articleModel=M('article');
        $this->articleTypeModel=M('articletype');
    }

    //查询类型列表数据
    public function queryTypeList($where,$filed=null){
        return $this->articleTypeModel->field($filed)->where($where)->select();
    }

    /**
     * 查询列表信息
     * @param $where
     * @param int $page
     * @param int $pageNum
     * @param null $filed
     * @return mixed
     */
    public function queryList($where,$page=1,$pageNum=20,$filed=null){
        //if(!empty($filed)){
        return $this->articleModel->field($filed)->where($where)->page($page,$pageNum)->order('article_id desc')->select();
        //}
    }

    /**
     * 查询详细信息
     * @param $where
     * @param null $filed
     * @return mixed
     */
    public function findDetail($where,$filed=null){
        if(!empty($filed)){
           return $this->articleModel->field($filed)->where($where)->find();
        }else{
            return $this->articleModel->field($filed)->where($where)->find();
        }
    }

}